﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PPIDesktopClient.General;

namespace PPIDesktopClient.Entities
{
    public class EBaseAsset : EBasePosition
    {
        #region Protected Members
        protected Int32 m_id;
        protected List<EBaseImage> m_Images;
        protected List<EBasePole> m_Poles;
        protected EXMissionStructures_TopType m_TopType;
        protected List<Int32> m_ListPolesDelete;
        protected List<Int32> m_ListImagesDelete;
        protected int m_UploadedImages;
        protected Int32 m_TotalImages;

        #endregion Miembros Privados

        #region Properties
        public Int32 Id
        {
            get
            {
                return m_id;
            }
            set
            {
                m_id = value;
            }
        }
        public Int32 TotalImages
        {
            get
            {
                return m_TotalImages;
            }
            set
            {
                m_TotalImages = value;
            }
        }
        public EXMissionStructures_TopType TopType
        {
            get
            {
                return m_TopType;
            }
            set
            {
                m_TopType = value;
            }
        }
        public List<Int32> PolesToDelete
        {
            get { return m_ListPolesDelete; }
        }
        public List<Int32> ImagesToDelete
        {
            get
            {
                return m_ListImagesDelete;
            }
        }
        public int UploadedImages
        {
            get
            {
                return m_UploadedImages;
            }
            set
            {
                m_UploadedImages = value;
            }
        }
        public bool AllowEdit
        {
            get { return (TotalImages == UploadedImages); }
        }
        public List<EBaseImage> Images
        {
            get
            {
                return m_Images;
            }
            set
            {
                m_Images = value;
            }
        }
        public List<EBasePole> Poles
        {
            get
            {
                return m_Poles;
            }
            set
            {
                m_Poles = value;
            }
        }

        #endregion

        #region Constructors

        public EBaseAsset()
            : base()
        {
            m_id = Int32.MinValue;
            m_TotalImages = 0;
            m_TopType = new EXMissionStructures_TopType();
            m_ListPolesDelete = new List<Int32>();
            m_ListImagesDelete = new List<Int32>();
            m_Images = new List<EBaseImage>();
            m_Poles = new List<EBasePole>();
        }


        #endregion

        #region Public Methods
        public Int32 Save()
        {
            if (m_id == Int32.MinValue)
            {
                m_id = Insert();
            }
            else
            {
                m_id = Update();
            }
            return m_id;
        }

        public void DeletePole(Int32 poleID)
        {
            m_ListPolesDelete.Add(poleID);
        }

        public void DeleteImage(Int32 ImageID)
        {
            m_ListImagesDelete.Add(ImageID);
        }

        #endregion

        #region Virtual Methods

        public virtual void Delete()
        {
            throw new NotImplementedException();
        }

        protected virtual Int32 Insert()
        {
            throw new NotImplementedException();

        }

        protected virtual Int32 Update()
        {
            throw new NotImplementedException();
        }

        public virtual EBaseAsset GetServer()
        {
            throw new NotImplementedException();
        }






        #endregion

        #region Override Methods

        protected override string GetHtmlName()
        {
            EUtility_QueryAssetTextShow title = GetTextToShow();
            string _Name = "";
            switch (title)
            {
                case EUtility_QueryAssetTextShow.Internal_Utility_ID:
                    _Name = "Visit [ " + m_id.ToString() + " ]";
                    break;
                case EUtility_QueryAssetTextShow.AID:
                    _Name = "Visit [  ]";
                    break;
                case EUtility_QueryAssetTextShow.Top_Type:
                    _Name = "Visit [ " + TopType.Name + " ]";
                    break;
                default:
                    break;
            }
            return _Name;
        }

        public override string GetHtmlDescription()
        {
            throw new NotImplementedException();
        }

       #endregion
    }
}
